package com.demo.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.demo.core.domain.Result;
import com.demo.domain.Post;
import com.demo.core.exception.ParameterException;
import com.demo.domain.ro.PageRequest;
import com.demo.domain.ro.SavePostRequest;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@Transactional
public interface PostService extends IService<Post> {

    Result getPostByCommentCount(PageRequest pageRequest, String sortBy, String searchKeyword, int type) throws ParameterException;

    /**
     * 获得所有帖子（分页）
     * @param currentPage
     * @param pageSize
     * @param post
     * @param isAscending
     * @param sortBy
     * @return
     */
    IPage<Post> getPage(int currentPage,int pageSize,Post post,Boolean isAscending,String sortBy) throws ParameterException;

    IPage<Post> getMyPost(int currentPage,int pageSize,Post post,Long uid) throws ParameterException;

    /**
     * 获取每个帖子
     * @param postId
     * @return
     */
    Post getPostById(Long postId) throws ParameterException;

    Result savePost(MultipartFile[] imageFiles, SavePostRequest savePostRequest,Long uid) throws IOException, ParameterException;

    /**
     * 发布帖子
     * @param post
     * @param images
     * @return
     */
    boolean savePostFlag(Post post,MultipartFile[] images) throws ParameterException, IOException;


}

